<?php

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
#	FILE:			includes/flash/savepageorder.php
#	FUNCTION:		Saves the page order from vars passed from Flash
#	AUTHOR:			Cameron Morrow
#	CREATED:		08/08/2005
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Report all errors
error_reporting(E_ALL);

# Start session
session_start();

# Use this for IE to remember form data correctly
header("Cache-control: private");

# Vars
$ERROR_ARRAY = array();
$SQL_ARRAY = array();

# Includes
include "../../site_specific/project.php";
include "../../includes/constants.php";
include "../../includes/utilities.php";
include "../../includes/pages.php";
include "../../includes/database.php";
include "../../includes/users.php";
include "../../includes/files.php";
include "../../includes/date.php";


# Establish database connection
establishDatabaseConnection();

# Get data from POST
$output = @$_POST["output"];

# Split into pages
$output = explode(",", $output);

foreach ($output as $page_order_array) {

	# Split
	$page_order_array = explode("|", $page_order_array);

	# Create SQL
	$sql = "UPDATE " . $PROJECT_DB_TABLES["pages"] . " SET p_sort = " . $page_order_array[1] . ", p_parent ='" . $page_order_array[2] . "', p_section = '" . $page_order_array[3] . "' WHERE p_id = '" . $page_order_array[0] . "'";
	
	# Execute
	if (executeSQLQuery($sql)) {

		# Log
		addLog("", 12, 4, $_SESSION[$PROJECT_CODE . "id"]);
	}

}

if (count($ERROR_ARRAY) == 0) {
	echo "success=true";
} else {
	echo "success=false";
}
?>